package com.huadao.pda.modle;

import android.content.Context;

import com.huadao.pda.base.BaseHttpModel;
import com.huadao.pda.data.bean.Project;
import com.huadao.pda.data.bean.ProjectListByPage;
import com.huadao.pda.data.http.Api;
import com.huadao.pda.data.http.BaseResponse;
import com.huadao.pda.data.http.HttpFunction;
import com.huadao.pda.data.http.RetrofitHelper;

import java.util.List;

import io.reactivex.Observable;

public class ProjectModel extends BaseHttpModel {
    private Api api;

    public ProjectModel(Context context) {
        api=RetrofitHelper.getInstance(context).create(Api.class);
    }

    public Observable<ProjectListByPage> getProjectList(int page, int pageSize){
        return api.getProjectByPage(page,pageSize).map(new HttpFunction());
    }

    public Observable<List<Project>> getAllProject(){
        return api.getAllProject().map(new HttpFunction());
    }

    public Observable<List<Project>> queryProject(String keyWord){
        return api.queryProject(keyWord).map(new HttpFunction());
    }

    public Observable<Boolean> bindingProject(String projectId, String deviceId){
        return api.bindingProject(projectId,deviceId).map(new HttpFunction());
    }

    public Observable bindingPDA(String id){
        return api.updateDeviceId(id).map(new HttpFunction());
    }
}